import {post,get} from './axios'
import {get_downLoad} from './axios_downLoad'

//刷新令牌
export function getRefreshToken() {
    return new Promise((resolve,reject)=>{
        get('/user/auth/refreshToken').then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}

//登录
export function authLogin(params:{}) { 
    return new Promise((resolve,reject)=>{
        post('/user/auth/login',params).then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}

//登录-图形验证
export function loginWithPic(params:{}) { 
    return new Promise((resolve,reject)=>{
        post('/user/auth/loginWithPic',params).then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}

//用户信息登录获取
export function getDetailByLogin() { 
    return new Promise((resolve,reject)=>{
        get('/user/user/queryDetailByLogin').then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}

//获取用户资源
export function queryMenuTree(params:{}) {
    return new Promise((resolve,reject)=>{
        // get('/user/resource/queryMenuTree',params).then((data)=>{
        get('/user/resource/multiPlatformMenuTree',params).then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}

//登陆成功获取用户项目信息
export function getUserProject() {
    return new Promise((resolve,reject)=>{
        get('/user/user/userProject').then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}

//图形验证码
export function getPicCaptcha() {
    return new Promise((resolve,reject)=>{
        get_downLoad('/user/captcha/getPicCaptcha').then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}

//验证图形验证码
export function verifyPicCaptcha(params:any) {
    return new Promise((resolve,reject)=>{
        post('/user/captcha/verifyPicCaptcha',params).then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}

//忘记密码
export function forgetPwd(params:any) {
    return new Promise((resolve,reject)=>{
        post('/user/user/forgetPwd',params).then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}

//用户修改个人密码
export function editInfoSelf(params:{}) {
    return new Promise((resolve,reject)=>{
        post('/user/user/editInfoSelf',params).then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}

//用户详情
export function queryUserDetail(id:string) { 
    return new Promise((resolve, reject)=>{
        get('/user/user/queryUserDetail/' + id).then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}

//退出登录
export function authLogout() { 
    return new Promise((resolve,reject)=>{
        post('/user/auth/logout').then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}

//用户修改个人密码
export function editPwdSelf(params:{}) {
    return new Promise((resolve,reject)=>{
        post('/user/user/editPwdSelf',params).then((data)=>{
            resolve(data);
        }).catch((error)=>{
            reject(error)
        })
    })
}



